package com.hh.commen;/*
 * @Auther:ZhengXueCheng
 * @Date:2023/7/24
 * @VERSON:1.8
 */

import com.hh.commen.bean.*;
import com.hh.utils.ResultVo;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
public class PublicDownList {
   /* @PostMapping("metadata/getPullDownList")
    public ResultVo getPullDownList() {
        List<Status> statusList = new ArrayList<>();
        statusList.add(new Status("全部", null));
        statusList.add(new Status("启用", 1));
        statusList.add(new Status("禁用", 0));
//        return ResultVo.success(statusList);

        List<GeneralData> jizhang = new ArrayList<>();
        jizhang.add(new GeneralData("记账成本","1"));

        List<GeneralData> money = new ArrayList<>();
        money.add(new GeneralData("人民币","money1"));
        money.add(new GeneralData("美元","money2"));
        return ResultVo.success(statusList,jizhang,money);
    } */

    @PostMapping("metadata/getPullDownList")
    public ResultVo getPullDownList(@RequestBody List<String> nameList) {
        Map<String,List<XiaLaVo>> listMap = new HashMap<>();
        Map<String,List<XiaLaVo>> resultMap = new HashMap<>();
        List<XiaLaVo> statusList = new ArrayList<>();
        for(StatusEnum statusEnum:StatusEnum.values()){
            XiaLaVo xiaLaVo = new XiaLaVo(statusEnum.getValue(),statusEnum.getName());
            statusList.add(xiaLaVo);
        }
        listMap.put("status",statusList);
        List<XiaLaVo> currencyList = new ArrayList<>();
        for(CurrencyEnum currencyEnum:CurrencyEnum.values()){
            XiaLaVo xiaLaVo = new XiaLaVo(currencyEnum.getValue(),currencyEnum.getName());
            currencyList.add(xiaLaVo);
        }
        listMap.put("currencyCode",currencyList);

        List<XiaLaVo> jizhangList = new ArrayList<>();
        for(PriceTypeEnum priceTypeEnum:PriceTypeEnum.values()){
            XiaLaVo xiaLaVo = new XiaLaVo(priceTypeEnum.getValue(),priceTypeEnum.getName());
            jizhangList.add(xiaLaVo);
        }
        listMap.put("priceType",jizhangList);

        for (String name:nameList){
            for (String key:listMap.keySet()){
                if (key.equals(name)){
                    resultMap.put(key,listMap.get(key));
                }
            }
        }

        return ResultVo.success(resultMap);
    }

}
